package artid.com.arttogoa;

import artid.com.arttogoa.R;

import artid.com.arttogoa.barcode.Cache;
import artid.com.arttogoa.parser.NoticeDetailParser;
import artid.com.arttogoa.volley.BitmapCache;
import artid.com.arttogoa.volley.VolleyBasic;
import artid.com.arttogoa.volley.VolleyCallback;
import artid.com.arttogoa.volley.VolleyData;
import artid.com.arttogoa.volley.VolleyMap;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import com.android.volley.toolbox.ImageLoader.ImageListener;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 
 *    
 * 项目名称：ArtworkArtA   
 * 类名称：NoticeDetailActivity   
 * 类描述：通知详情页   
 * 创建人：耿卫斌  
 * 创建时间：2016年5月16日 下午2:28:58      
 *
 */
public class NoticeDetailActivity extends BaseActivity implements OnClickListener{
	private String id;
	private ImageView mImage;
	private TextView title,address,time,content;
	private ImageLoader mImageLoader;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_notice_detail);
		setContent(this, getIntent());
		mContext=NoticeDetailActivity.this;
		initView();
		
	}
	private void initView(){
		id=getIntent().getStringExtra("id");
		RequestQueue mQueue = Volley.newRequestQueue(mContext);
		mImageLoader = new ImageLoader(mQueue, new BitmapCache());
		mTittle = (TextView) findViewById(R.id.title_text);
		mTittle.setText("通知详情页");
		setBack();
		mImage=(ImageView) findViewById(R.id.NoticeDetail_img);
		title=(TextView) findViewById(R.id.NoticeDetail_title);
		address=(TextView) findViewById(R.id.NoticeDetail_address);
		time=(TextView) findViewById(R.id.NoticeDetail_time);
		content=(TextView) findViewById(R.id.NoticeDetail_content);
		getNoticeDetailInfo(id);
	}

	@Override
	public void onClick(View v) {
	}
	/**
	 * 获取详情
	 */
	private void getNoticeDetailInfo(String id){
		VolleyBasic.getInstance(NoticeDetailActivity.this).post(Cache.noiceInfo,
				VolleyMap.getInstance().noiceInfo(id), NoticeDetailParser.class,new VolleyCallback() {
			public void onSuccess(VolleyData vd) {
				// TODO Auto-generated method stub
				System.out.println(vd.getJson());
				NoticeDetailParser bean=(NoticeDetailParser) vd.getData();
				ImageListener listener = ImageLoader.getImageListener(mImage, android.R.drawable.ic_menu_rotate,android.R.drawable.ic_delete);
				mImageLoader.get(bean.getPath(),listener);
				title.setText(bean.getTitle());
				content.setText(bean.getContent());
			}
			public void onError(VolleyError volleyError) {
			}
		});
	}
}
